package com.secneo.appshare.activities;

import com.secneo.appshare.R;
import com.secneo.appshare.api.LocalStore;
import com.secneo.appshare.common.Constants;
import com.secneo.mp.api.database.DatabaseHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class UserInfoActivity extends Activity{

	TextView mBNumberTv ;
	TextView mNicknameTv ;
	TextView mPasswordTv ;
	Button mNextPre ;
	
	int snsType;
	
	int bNumber ;
	String nickName ;
	String password ;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.user_info) ;
		
	    Bundle bundle = getIntent().getExtras();
	    snsType=bundle.getInt("sns_type");
		
//		loadIntent() ;
		initViews() ;
	}
	
	private void initViews(){
		LocalStore ls = LocalStore.getLocaleStoreInstance(this) ;
		mBNumberTv = (TextView)findViewById(R.id.bnumber) ;
		String tmp = getResources().getString(R.string.txt_bnumber) ;
		mBNumberTv.setText(tmp + ls.getAndroidId()) ;
		
		mNicknameTv = (TextView)findViewById(R.id.nick_name) ;
		tmp = getResources().getString(R.string.txt_nick_name) ;
		mNicknameTv.setText(tmp + ls.getNickName()) ;
		
		mPasswordTv = (TextView)findViewById(R.id.password) ;
		tmp = getResources().getString(R.string.txt_password) ;
		mPasswordTv.setText(tmp + "123456") ;
		
		mNextPre = (Button)findViewById(R.id.next_pre) ;
		mNextPre.setOnClickListener(nextPreListener) ;
	}
	
	private final OnClickListener nextPreListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			DatabaseHelper dh=new DatabaseHelper(UserInfoActivity.this);
			dh.insertUserAppPopularityBycatagory(UserInfoActivity.this,2051);
			dh.close();
			
			Intent intent = new Intent(UserInfoActivity.this,  
					ChooseUserActivity.class) ;
			Bundle mBundle = new Bundle(); 
			mBundle.putInt("sns_type", snsType);
			intent.putExtras(mBundle);
			startActivity(intent) ;
			finish() ;
		}
	};
	
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
			return true ;
		} else {
			return super.onKeyDown(keyCode, event) ;
		}
		
	}	
	
}
